//
//  HTSubjectCell.swift
//  MagaCore
//
//  Created by MrMessy on 2023/5/4.
//

import SwiftUI

struct HTSubjectCell: View {

  var var_anime: HTAnime = HTAnime()

  var body: some View {
    VStack(alignment: .leading, spacing: 0) {
      HStack(alignment: .top, spacing: 10){
        HTCoverView(var_anime: var_anime, var_width: UIDevice.ht_fixToWidth(width: 76), var_height: UIDevice.ht_fixToWidth(width: 112))
        VStack(alignment: .leading, spacing: 4){
          Text(var_anime.var_title ?? "")
            .foregroundColor(Color(hex: "#393939"))
            .font(.system(size: UIDevice.ht_fixToWidth(width: 16)))
            .fontWeight(.bold)
            .lineLimit(2)
            .padding(.top, 5)
            .multilineTextAlignment(.leading)
          if var_anime.var_title_2 != "" {
            Text(var_anime.var_title_2 ?? "")
              .font(.system(size: UIDevice.ht_fixToWidth(width: 12)))
              .lineLimit(1)
              .foregroundColor(Color(hex: "#999999"))
          }
          Text(var_anime.var_pub_date ?? "")
            .font(.system(size: UIDevice.ht_fixToWidth(width: 12)))
            .lineLimit(1)
            .foregroundColor(Color(hex: "#999999"))
          Spacer()
          HStack(spacing: 4) {
            if (var_anime.var_ep != nil) {
              HTTagView(var_name: var_anime.var_ep ?? "", var_nameColor: Color(hex: "#FF6C3C"), var_tagColor: Color(hex: "#FF6C3C").opacity(0.1))
            }
            if (var_anime.var_dub == "1") {
              HTTagView(var_name: "DUB")
            }
            if (var_anime.var_sub == "1") {
              HTTagView(var_name: "SUB")
            }
          }
          .padding(.bottom, 5)
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
      }
      .frame(maxWidth: .infinity, maxHeight: .infinity)
      .padding(.trailing, 15)
      .padding(.vertical, 15)
      Divider()
    }
    .frame(maxWidth: .infinity, maxHeight: .infinity)
    .padding(.leading, 15)
  }
}
